<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>近期活动</title>
<style type="text/css">
/*   body{text-align: center}
  table{font-size: 12px;width: 80%;}
  tr{height: 30px}
  .td{text-align: right} */
</style>
</head>

<link rel="stylesheet"
	href="<%=basePath%>kindeditor/themes/default/default.css" />
<link rel="stylesheet"
	href="<%=basePath%>kindeditor/plugins/code/prettify.css" />
<link rel="stylesheet" href="<%=basePath%>ui/css/edit.css" />
<script type="text/javascript"
	src="<%=basePath%>kindeditor/kindeditor.js"></script>
<script type="text/javascript"
	src="<%=basePath%>kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript"
	src="<%=basePath%>kindeditor/plugins/code/prettify.js"></script>
<script charset="utf-8"
	src="<%=basePath%>kindeditor/kindeditor-myconfig-org.js"></script>
<script type="text/javascript">
var info=[
{"name": "微博", "type":"wb" },
{"name": "微信", "type":"wx"},
{"name": "大众点评网", "type":"dz"},
{"name": "拉手网", "type":"ls"},
{"name": "QQ链接", "type":"qq"},
{"name": "其他", "type":"qt"}
];
$(function(){
/* 	$("#mesCatagory").empty();
	var html="";
	var mesCatagory="${entity.mesCatagory}";
	$(info).each(function(){
		   if(mesCatagory && mesCatagory == this.type)
			html+="<option value="+this.type+" selected>"+this.name+"</option>";
			else
				html+="<option value="+this.type+">"+this.name+"</option>";
	});
	$("#mesCatagory").append(html); */
	editor = KindEditor.create('#editer1', {
		  
		  width:'100%',height:'440px',
		 
		   cssPath : '/kindeditor/plugins/code/prettify.css',
		  filterMode:false,
		  
		  uploadJson:'/kindeditor/jsp/upload_json.jsp'
			  ,langType : 'zh_CN',items:KE_simple,resizeType:0
	});
	prettyPrint();
});
function checkContent() {
	var mesName=$("#mesName").val();
	if(!mesName){
		alert("请输入标题！");
		return false;
	}	
	
	var mesSubtitle=$("#mesSubtitle").val();
	if(!mesSubtitle){
		alert("请输入二级标题！");
		return false;
	}

	var file=$("#file").val();
	var id=$("#id").val();
	//debugger;
	if(!id && !file ){
		if(!file){
			alert("请上传附件！");
			return false;
		}
	}
	if(file){
		var type=file.substring(file.lastIndexOf('.')+1,file.length).toLowerCase();
		if(type!='jpg' && type !='gif' && type !='png' && type!='bmp'){
			alert("请上传图片格式附件");
			return false;
		}
	}
		var content = editor.text();
	if (editor.isEmpty()) {
		alert("请输入内容！");
		return false;
	}
	if (content.length > 20000) {
		alert("内容长度不能超过20000字！");
		return false;
	}
	var content2 = editor.html();
	$("#editer1").val(content2);
	return true;
}
</script>
<body>
	<form action="${basePath}newsActivity/saveActivity.html" id="myform"
		method="post" onsubmit="return checkContent()"
		enctype="multipart/form-data">
		<input type="hidden" name="porCode" value="${porCode}"> <input
			type="hidden" name="id" id="id" value="${entity.id}"> <input
			type="hidden" name="type" value="${type}">
		<table cellspacing="0" cellpadding="0" border="0" class="addclass">
			 <tr>
	  		    <td colspan="2><div class="nav"><%@ include file="/common/nav.jsp"%></div></tr>
	  		  </tr>
			<tr>
				<td width="20%" class="trLeft">标题：</td>
				<td><input type="text" name="mesName" id="mesName"
					value="${entity.mesName}" maxlength="60"></td>
			</tr>
			<tr>
				<td width="20%" class="trLeft">二级标题：</td>
				<td><input type="text" name="mesSubtitle" id="mesSubtitle"
					value="${entity.mesSubtitle}" maxlength="160"></td>
			</tr>
		
			<tr>
				<td width="20%" class="trLeft">是否首页显示：</td>
				<td><c:if test="${empty entity.id }">
						<input type="radio" name="mesIfreview" value="1" checked="checked" class="otherInput">是
				     <input type="radio" name="mesIfreview" value="0" class="otherInput" >否
				</c:if> <c:if test="${not empty entity.id }">
						<input type="radio" name="mesIfreview" value="1" class="otherInput" <c:if test="${entity.mesIfreview ==1}">  checked="checked" </c:if>>是
				        <input type="radio" name="mesIfreview" value="0" class="otherInput" <c:if test="${entity.mesIfreview ==0}">  checked="checked" </c:if>>否
				 </c:if></td>
			</tr>
			<tr>
				<td width="20%" class="trLeft" valign="top">附件：</td>
				<td><input type="file" name="file" id="file" class="fileInput"><br>
					<input name="mesAccessory" type="hidden"
					value="${entity.mesAccessory }"> <c:if
						test="${not empty entity.mesAccessory}">
						<img src="<%=uiPath %>${entity.mesAccessory}" width="200"
							height="132">
					</c:if></td>
			</tr>
			<tr>
				<td valign="top" class="trLeft">内容：</td>
				<td><textarea id="editer1" name="mesContent"
						style="width:700px;height:300px;">${entity.mesContent }</textarea></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align: center"><input
					class="button" type="submit" value="提交" id="save"></td>
				<!-- onclick="save()" -->
			</tr>
		</table>
	</form>

</body>
</html>
